package gen.kaynak.navitrack.messageProcessState;

import gen.kaynak.navitrack.messageProcessStrategy.*;

public class CoordinateDiscovered extends ACMessageProcessState {
	private static CoordinateDiscovered state = new CoordinateDiscovered();
	private MessageProcessStrategyManager objCLLP;

	private CoordinateDiscovered() {

	}

	public static ACMessageProcessState Instance() {
		return state;

	}

	@Override
	void ProcessWhiteSpace(char c, MessageProcessStateManager mpm) {
		if (mpm.alternateProcessing()) {
			ChangeState(mpm, Initial.Instance());
		} else {
			mpm.terminateProcessManager();
			// Exit Sub
		}

	}

	@Override
	void ProcessLetter(char c, MessageProcessStateManager mpm) {
		if (mpm.alternateProcessing()) {
			ChangeState(mpm, Initial.Instance());
			objCLLP = new MessageProcessStrategyManager(new NSEWProcessor());
			if (objCLLP.Process(c, mpm)) {
				ChangeState(mpm, NSEWDiscovered.Instance());
			}
		} else {
			mpm.terminateProcessManager();
			//        Exit Sub
		}

	}

	@Override
	void ProcessPunctuation(char c, MessageProcessStateManager mpm) {
		if (mpm.alternateProcessing()) {
			ChangeState(mpm, Initial.Instance());
		} else {
			mpm.terminateProcessManager();
			// Exit Sub
		}

	}

	@Override
	void ProcessSymbol(char c, MessageProcessStateManager mpm) {
		if (mpm.alternateProcessing()) {
			switch (c) {
			case '+':
				ChangeState(mpm, Initial.Instance());
				mpm.setSign("+");
				ChangeState(mpm, NSEWDiscovered.Instance());
			case '-':
				ChangeState(mpm, Initial.Instance());
				mpm.setSign("-");
				ChangeState(mpm, NSEWDiscovered.Instance());
			default:
				ChangeState(mpm, Initial.Instance());
			}
		} else {
			mpm.terminateProcessManager();
			// Exit Sub
		}

	}

	@Override
	void ProcessNumber(char c, MessageProcessStateManager mpm) {
		if (mpm.alternateProcessing()) {
			ChangeState(mpm, Initial.Instance());
			mpm.appendChar(c);
			ChangeState(mpm, DegreeIntegerProcessing.Instance());
		} else {
			mpm.terminateProcessManager();
			// Exit Sub
		}

	}

}